home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 2 / Mac Magazin and MacEasy Magazine CD - Issue 02.iso / Sharewarebibliothek / Applikationen / Alpha.5.81 folder / Tcl / UserCode / update.tcl < prev    next >
Text File  |  1994-03-08  |  3KB  |  86 lines

  1. # FILE: update.tcl
  2. #
  3. # LAST UPDATE: 01/06/93 4:45:33 AM
  4. #
  5. # This file contains the following TCL procedure(s):
  6. #
  7. #     update  -- automatically updates timestamp on a file
  8. #
  9. #     Just add a line with 'LAST UPDATE: 01/2/34 5:67:89 AM' within the 
  10. #     first 500 characters of your file. Also add an alias of the form 
  11. #     {electricAlias def "" "UPDATE:" "UPDATE:§«update»"}. Now select the 
  12. #     space after the colon (:) and type DELETE TAB...you get a line similar 
  13. #     to: LAST UPDATE: 01/06/93 4:51:50 AM 
  14. #     This proc is useful with electricAlias definitions (ie. §«update»).
  15. #    In fact the date on THIS file is maintained thusly.
  16. #
  17. #    To use, simply source this file place it in the a folder with the
  18. #    name $HOME:Tcl:Usercode: and invoke it implicitly via the "unknown proc".
  19. #
  20. # SEE ALSO unknown.tcl, electricAlias.tcl
  21.  
  22. # COPYRIGHT:
  23. #
  24. #    Copyright © 1992,1993 by David C. Black
  25. #    All rights reserved.
  26. #
  27. #    Redistribution and use in source and binary forms are permitted
  28. #    provided that the above copyright notice and this paragraph are
  29. #    duplicated in all such forms and that any documentation,
  30. #    advertising materials, and other materials related to such
  31. #    distribution and use acknowledge that the software was developed
  32. #    by David C. Black.
  33. #
  34. #    THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
  35. #    IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  36. #    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  37. #
  38. ################################################################################
  39.  
  40. # AUTHOR
  41. #
  42. #    David C. Black
  43. #    Internet: black@mpd.tandem.com (preferred)
  44. #    GEnie:    D.C.Black
  45. #    USnail:   6217 John Chisum Lane, Austin, TX 78749
  46. #
  47. ################################################################################
  48.  
  49. # HISTORY
  50. #                  
  51. # modified who rev reason
  52. # -------- --- --- ------
  53. # 01/06/93 DCB 1.0 Original
  54.  
  55. proc update {args} {
  56.     set max [maxPos]
  57.     if {$max > 500} {
  58.         set max 500
  59.     }
  60.     set pos [getPos]
  61.     set end [selEnd]
  62.     set text [getText 0 $max]
  63.     set hour {[0-9][0-9]?:[0-9][0-9]:[0-9][0-9] [AP]M}
  64.     set date {[0-9][0-9]?/[0-9][0-9]?/[0-9][0-9]}
  65.     set patt "LAST UPDATE ?: ( *$date $hour)"
  66.     if {![regexp -indices $patt $text all datePos]} {
  67.         return ""
  68.     }
  69.     set p1 [lindex $datePos 0]
  70.     set p2 [expr {[lindex $datePos 1]+1}]
  71.     set text [getText $p1 $p2]
  72.     set time [mtime [now] short]
  73.     if {$text == $time} {
  74.         return ""
  75.     }
  76.     replaceText $p1 $p2 $time
  77.     goto $pos
  78.     select $pos $end
  79.     return ""
  80. }
  81. #endproc update
  82. ################################################################################
  83.  
  84.